package com.ssy.invoicing.invouser.dao;

import java.sql.SQLException;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.ssy.invoicing.dao.support.BaseSqlDao;
import com.ssy.invoicing.invouser.bean.InvoUser;

/**
 * Comment of InvoUserDao
 * @author wb_suoyao.shen
 */
@Repository(value="invoUserDao")
public class InvoUserDao extends BaseSqlDao {
    
    /**
     * @param params
     * @param page
     * @return
     * @throws SQLException
     */
    public SplitPageResult queryUserListByPage(Map<String, Object> params, int page)
            throws SQLException {
        return queryListByPagination("invouser.queryUserListByPage", "invouser.queryInvoUserCount",
                params, page);
    }

    /**
     * 根据用户名获得用户信息
     * @author suoyao.shen
     * @param name
     * @return
     */
    public InvoUser getInvoUserByName(String name) {
        return (InvoUser) queryForObject("invouser.getInvoUserByName", name);
    }
    
    /**
     * 根据用户Id获得用户信息
     * @param id
     * @return
     */
    public InvoUser getInvoUserById(Integer id) {
        return (InvoUser) queryForObject("invouser.getInvoUserById", id);
    }
    
    public void saveUser(InvoUser user) {
        insert("invouser.insertInvoUser", user);
    }
    
    /**
     * @param user
     */
    public void updateUser(InvoUser user) {
        update("invouser.updateInvoUser", user);
    }
    
    /**
     * @param id
     */
    public void removeUser(Integer id) {
        delete("invouser.removeInvoUser", id);
    }
    
}
